; Crappy SNDH-player
;
; sndh.s
;
; May 30, 2003
;
; Anders Eriksson
; ae@dhs.n

		section	text


init_sndh:
		move.l	filebuffer,a0			;init sndhfile
		moveq.l	#1,d0
		jsr	(a0)				;

		move.w	sr,d0				;init our own timer-c
		move.w	#$2700,sr			;
		move.l	$114.w,save_c			;
		move.l	#play_sndh,$114.w		;
		move.w	d0,sr				;



		rts
		


play_sndh:	movem.l	d0-a6,-(sp)			

		move.w	sndh_speed,d0			;Hz of the SNDH
		sub.w	d0,sndh_fill			;decrease timer value
		bpl.s	.no				;if <0 play
		add.w	#200,sndh_fill			;timer speed add

		move.l	filebuffer,a0			;sndhfile
		jsr	8(a0)				;play
.no:		movem.l	(sp)+,d0-a6
		move.l	save_c,-(sp)			;run system timer-c
		rts

sndh_speed:	dc.w	50
sndh_fill:	dc.w	200



exit_sndh:
		move.w	sr,d0				;restore old timer-c
		move.w	#$2700,sr			;
		move.l	save_c,$114.w			;
		move.w	d0,sr				;

		move.l	filebuffer,a0			;deinit sndh
		jsr	4(a0)				;

		rts



